<template>
	<view class="container">
		<scroll-view class="scroll-view" scroll-y enable-flex scroll-with-animation refresher-enabled :refresher-triggered="isPullRefresh" @refresherrefresh="refreshList">
			<view :class="'content ' + (careerInfo.projectList?.length == 0 ? 'no-content' : '')">
				<view class="info">
					<image class="avatar" :src="careerInfo.avatarData" v-if="careerInfo.avatar && finish" mode="aspectFill" />
					<view :class="'icon-container ' + (careerInfo.personType != '10' ? 'orange' : 'green')" v-if="!careerInfo.avatar && finish">
						<icon type="icon-a-laowurenyuan1x" :size="64" v-if="careerInfo.personType != '10'" />
						<icon type="icon-a-guanlirenyuan1x" :size="64" v-else />
					</view>
					<view class="name">{{ careerInfo.name }}</view>
				</view>
				<view class="career">
					<view class="project-list" v-if="careerInfo.projectList && careerInfo.projectList.length != 0">
						<view class="project-item" v-for="(projectItem, projectIndex) in careerInfo.projectList" :key="projectIndex">
							<view class="project-content">
								<view class="project-circle"></view>
								<view class="project-line"></view>
								<view class="project-name">{{ projectItem.projectName || '项目名称：-' }}</view>
							</view>

							<view class="career-list">
								<view class="career-item" v-for="(careerItem, careerIndex) in projectItem.career" :key="careerIndex">
									<view class="career-circle"></view>

									<view class="career-line"></view>

									<view class="career-content">
										<view class="career-content-top">
											<view class="time">{{ careerItem.date }}</view>
											<view class="work-type" v-if="careerItem.worktypeOrStationName">{{ careerItem.worktypeOrStationName }}</view>
											<view :class="'state ' + (careerItem.workingStatus == 2 ? 'off' : '') + ' ' + (careerItem.worktypeOrStationName ? '' : 'sp')">
												{{ careerItem.workingStatus == 1 ? '在岗' : '离岗' }}
											</view>
										</view>
										<view class="career-content-bottom">
											<text>{{ careerItem.orgName || '组织机构：-' }}</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="no-data" v-else>
						<no-data></no-data>
					</view>
				</view>
			</view>
			<view class="gray-block"></view>
		</scroll-view>
	</view>
</template>

<script>
import noData from '@/pagesA/components/common/no-data/no-data';
const app = getApp();
export default {
	components: {
		noData
	},
	data() {
		return {
			avatar: '',
			name: '',
			phoneNumber: '',
			projectList: [],
			finish: false,
			isPullRefresh: false,
			projectIndex: 0,
			projectItem: {
				projectName: '',
				career: []
			},
			careerIndex: 0,
			careerItem: {
				date: '',
				worktypeOrStationName: '',
				workingStatus: 0,
				orgName: ''
			}
		};
	},
	props: {
		careerInfo: {
			type: Object
		}
	},
	methods: {
		refreshList() {
			this.isPullRefresh = true;
			this.$emit('refreshlist', {
				detail: {
					personType: this.careerInfo.personType
				}
			});
		}
	},
	created: function () {},
	watch: {
		careerInfo: {
			handler: function (value) {
				if (value.finish) {
					// this.setData({
					// 	finish: true,
					// 	isPullRefresh: value.isPullRefresh
					// });
					this.finish = true;
					this.isPullRefresh = value.isPullRefresh;
				}
			},
			immediate: true,
			deep: true
		}
	}
};
</script>
<style>
.container {
	width: 100vw;
	height: 100%;
	background-color: #f6f7fa;
	display: flex;
	flex-direction: column;
}

.scroll-view {
	flex: 1;
	height: 0;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
}

.content {
	display: flex;
	flex-direction: column;
	margin: 24rpx 24rpx 0;
	background-color: #fff;
	padding: 0 32rpx;
	border-radius: 24rpx;
}

.no-content {
	height: inherit;
}

.no-data {
	height: 100%;
}

.info {
	display: flex;
	align-items: center;
	padding: 24rpx 0;
}

.info .avatar {
	width: 64rpx;
	height: 64rpx;
	border-radius: 12rpx;
	margin-right: 16rpx;
}

.info .icon-container {
	width: 64rpx;
	height: 64rpx;
	border-radius: 12rpx;
	margin-right: 16rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.icon-container.green {
	background-color: #00c467;
}

.icon-container.orange {
	background-color: #ff9544;
}

.info .name {
	font-size: 34rpx;
	font-family: PingFangSC-Medium, PingFang SC;
	font-weight: 550;
	color: #1e253f;
}

.career {
	padding: 12rpx 0 0 23rpx;
	display: flex;
	flex-direction: column;
	flex: 1;
}

.project-content {
	display: flex;
	position: relative;
}

.project-circle {
	display: flex;
	align-items: center;
	justify-content: center;
	position: absolute;
	width: 14px;
	height: 14px;
	background: #ffffff;
	border: 2rpx solid #949dbf;
	border-radius: 50%;
	top: 3px;
	left: -9px;
	z-index: 100;
}

.project-circle::before {
	display: flex;
	align-items: center;
	justify-content: center;
	content: '';
	width: 8px;
	height: 8px;
	background: #949dbf;
	border-radius: 50%;
}

.project-line {
	position: absolute;
	height: 95%;
	width: 2rpx;
	background: #949dbf;
	top: 34rpx;
	left: -2rpx;
}

.project-name {
	font-size: 32rpx;
	font-family: PingFangSC-Medium, PingFang SC;
	font-weight: 550;
	color: #1e253f;
	margin-left: 26rpx;
	margin-bottom: 28rpx;
}

.career-item {
	display: flex;
	position: relative;
	margin-bottom: 32rpx;
}

.career-circle {
	position: absolute;
	width: 10px;
	height: 10px;
	background: #ffffff;
	border: 2rpx solid #949dbf;
	border-radius: 50%;
	top: 30rpx;
	left: -14rpx;
	z-index: 100;
}

.career-line {
	position: absolute;
	height: calc(100% + 40rpx);
	width: 2rpx;
	background: #949dbf;
	top: 33rpx;
	left: -2rpx;
}

.career-content {
	margin-left: 20rpx;
	background-color: #f1f2f5;
	border-radius: 8rpx;
	padding: 20rpx 32rpx 20rpx;
}

.project-item:last-child .career-item:last-child .career-line {
	display: none;
}

.career-content {
	flex: 1;
}

.career-content-top {
	display: flex;
	margin-bottom: 18rpx;
	align-items: center;
}

.career-content-top .time {
	font-size: 32rpx;
	font-family: PingFangSC-Medium, PingFang SC;
	font-weight: 500;
	color: #1e253f;
}

.career-content-top .work-type,
.career-content-top .state {
	width: 80rpx;
	height: 40rpx;
	background: #65c344;
	border-radius: 6rpx;
	font-size: 24rpx;
	font-family: PingFangSC-Medium, PingFang SC;
	font-weight: 500;
	color: #fff;
	line-height: 40rpx;
	text-align: center;
}

.career-content-top .state.off {
	background: #ff555c;
}

.career-content-top .state.sp {
	margin-left: auto;
}

.career-content-top .work-type {
	width: auto;
	max-width: 180rpx;
	padding: 0 10rpx;
	height: 40rpx;
	background-color: #0a62cc;
	margin-right: 20rpx;
	margin-left: auto;
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
}

.career-content-bottom {
	display: flex;
	align-items: center;
	font-size: 28rpx;
	font-family: PingFangSC-Regular, PingFang SC;
	font-weight: 400;
	color: #4b5680;
	text-align: justify;
}

.career-content-bottom .text-line {
	width: 1rpx;
	height: 26rpx;
	font-weight: 0;
	background-color: #4b5680;
	margin: 0rpx 14rpx;
	position: relative;
	top: 2rpx;
}

.gray-block {
	padding: 12rpx;
}
</style>
